package com.tianci.appstore.ui.list;

import android.content.Context;

import com.tianci.appstore.ui.widget.SkyAppPager;

public class ListFlipper extends SkyAppPager {
    protected Context mContext;
    public static final int VIEW_PAGE_COUNT = 3;

    public ListFlipper(Context context, Direction direction) {
        super(context, direction);
        this.mContext = context;
    }

    @Override
    public void displayNextPage() {
        //setOutAnimation(outTopDown);
        //setInAnimation(inTopDown);
        super.displayPrePage();
        int crtIndex = this.getDisplayedChild();
        if (this.getDisplayedChild() < VIEW_PAGE_COUNT - 1)
            this.setDisplayedChild(crtIndex + 1);
        else
            this.setDisplayedChild(0);
    }

//    private SkyCustomLayout getPreviousChild(int index)
//    {
//        if(index > 0)
//            return (SkyCustomLayout) this.getChildAt(index - 1);
//        if(index == 0)
//            return (SkyCustomLayout) this.getChildAt(VIEW_PAGE_COUNT - 1);
//        return null;
//    }
//    
//    private SkyCustomLayout getNextChild(int index)
//    {
//        if(index < VIEW_PAGE_COUNT - 1)
//            return (SkyCustomLayout) this.getChildAt(index + 1);
//        if(index == VIEW_PAGE_COUNT - 1)
//            return (SkyCustomLayout) this.getChildAt(0);    
//        return null;
//    }

    @Override
    public void displayPrePage() {
        //setInAnimation(inDownTop);
        //setOutAnimation(outDownTop);
        super.displayPrePage();
        if (this.getDisplayedChild() > 0)
            this.setDisplayedChild(this.getDisplayedChild() - 1);
        else
            this.setDisplayedChild(VIEW_PAGE_COUNT - 1);
    }

    public void hitBoundary(int direction) {

    }
}
